package com.cyf.util;

import java.text.DecimalFormat;

/**
 * App相关工具类
 * Created by cage on 2017/4/21.
 */
public class ParkingUtil {

    private static DecimalFormat decimalFormat = new DecimalFormat("0.00");

    /**
     * 对车场名称进行处理
     * @param name  不为null
     * @return
     */
    public static String getParkingName(String name) {
        name = name.trim();
        if (name.endsWith("停车场")) {
            name = name.substring(0, name.length() - 3);
        }
        if (name.length() <= 2) {
            name = "";
        } else if (name.length() <= 4) {
            name = name.substring(0, 2);
        } else {
            name = name.substring(0, 4);
        }
        return name + "***停车场";
    }

    public static String getFee(Integer fee) {
        if (fee == null) {
            return "0";
        }
        if (fee % 100 == 0) {
            return fee/100 + "";
        } else {
            return decimalFormat.format(fee * 0.01);
        }
    }
}
